package map;



import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.geom.Vector2f;

import animation.MacAnimation;

import constans.Global;
import constans.ResourceManager;

public class Map {

	private Sector[][] sector;
	public static Vector2f shift;
	public static int margin = 50;
	
	SpriteSheet sheet = new SpriteSheet(ResourceManager.getImage("lava"), 600,600);
	Animation animation = new Animation(sheet, 150);
	
	public Map()
	{
		animation.setPingPong(true);
		shift = new Vector2f(-Global.VIEW_SIZE/2,-Global.VIEW_SIZE/2);
		
		sector = new Sector[Global.MAP_SIZE_X/Sector.size][Global.MAP_SIZE_Y/Sector.size];
		for(int i = 0 ; i <Global.MAP_SIZE_X/Sector.size ; i++)
			for(int j = 0 ; j <Global.MAP_SIZE_Y/Sector.size ; j++)
				sector[i][j] = new Sector(i*Sector.size,j*Sector.size);
	
	}
	public void render(GameContainer container, Graphics g) throws SlickException
	{	
		animation.draw(0, 0);
		for(Sector[] s1 : sector)
			for( Sector s2 : s1)
				s2.render(container, g);
	}
	public void update(GameContainer container, int delta) throws SlickException
	{		
	}
	public static void setShift(Vector2f p, Vector2f m)
	{
		//if(p < Global.m)
		
	}

}
